<template>
  <div class="home">
    <h1>首页</h1>
    <van-card
      v-for="item in list"
      :key="item.id"
      :price="item.sell_price"
      :desc="item.zhaiyao"
      :title="item.title"
      :thumb="item.img_url"
      @click="gotodetail(item.id)"
    />
  </div>
</template>

<script>
export default {
  data() {
    return {
      list: [],
    };
  },
  mounted() {
    this.$axios.get("/api/getgoods?pageindex=1").then((res) => {
      console.log(res);
      this.list = res.data.message;
    });
  },
  methods: {
    gotodetail(id) {
      this.$router.push({
        path: "/detail",
        query: {
          id: id,
        },
      });
    },
  },
};
</script>
